{extend name='common/_container'}
{block name="content"}
<div class="ibox float-e-margins">
	<div class="ibox-content layui-form">
		<div class="form-horizontal" id="CodeInfoForm">
			<div class="row">
				<div class="col-sm-7">
				<!-- form start -->
					<div class="form-group">
						<label class="col-sm-2 control-label">新密码：</label>
						<div class="col-sm-6">
							<input type="password" id="password"  name="password" class="form-control" placeholder="请输入新密码">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">确认密码：</label>
						<div class="col-sm-6">
							<input type="password" id="repassword" name="repassword" class="form-control" placeholder="请输入确认密码">
						</div>
					</div>
					
					
				<!-- form end -->
				</div>
			</div>
			<div class="row btn-group-m-t">
				<div class="col-sm-9">
					<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.updatePassword()" id="ensure">
						<i class="fa fa-check"></i>&nbsp;确认提交
					</button>
					<button type="button" class="btn btn-danger" onclick="CodeInfoDlg.close()" id="cancel">
						<i class="fa fa-eraser"></i>&nbsp;取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
var CodeInfoDlg = {
	CodeInfoData: {},
	validateFields: {
		password: {
			validators: {
				notEmpty: {
					message: '新密码不能为空'
	 			},
				regexp: {
					regexp: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/,
					message: '6-21字母和数字组合'
	 			},
	 		}
	 	},
		repassword: {
			validators: {
				notEmpty: {
					message: '确认密码不能为空'
	 			},
				identical: {
					field: 'password',
					message: '两次密码输入不一致'
                }
	 		}
	 	}
	 }
}

CodeInfoDlg.collectData = function () {
	this.set('password');
};

CodeInfoDlg.updatePassword = function () {
	 this.clearData();
	 this.collectData();
	 if (!this.validate()) {
	 	return;
	 }

	 var tip = '修改';
	 var ajax = new $ax(Feng.ctxPath + "/Base/password", function (data) {
	 	if ('00' === data.status) {
	 		Feng.success(tip + "成功" );
	 		window.parent.CodeGoods.table.refresh();
	 		CodeInfoDlg.close();
	 	} else {
	 		Feng.error(tip + "失败！" + data.msg + "！");
		 }
	 }, function (data) {
	 	Feng.error("操作失败!" + data.responseJSON.message + "!");
	 });
	 ajax.set('password',password);
	 ajax.set(this.CodeInfoData);
	 ajax.start();
};


</script>
<script src="__PUBLIC__/static/js/base.js" charset="utf-8"></script>
{/block}
